﻿using System;
using Common.Logging;
using System.Reflection;
using System.Diagnostics;
using System.IO;

namespace DotNetNexusSpam
{
    class Program
    {
        static void Main(string[] args)
        {
            ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 
            _log.Debug("Welcome to DotNetNexusSpam - Version 1.4 Freeware");
            _log.Debug("Copyright © 2006 - 2010 Nexus Digital Technology.\n");

            string idEmail = "", connectorCode = "";
            // uncomment following lines if you want to hard code the email's info
            // email will be looked up inside the Mail Enable's directory.
            //idEmail = "RMTAP.MAI";
            //connectorCode = "SMTP";
            bool argsAreFromCommandLine = ProgramUtil.GetCommandLineArgs(ref idEmail, ref connectorCode);

            SpamFilterEngine filterEnginer = new SpamFilterEngine(idEmail, connectorCode);
            filterEnginer.StartFilter();

            // keep console open only when program is invoked from command line.
            if (!argsAreFromCommandLine)
            {
                while (true)
                {
                    idEmail = connectorCode = "";
                    ProgramUtil.GetCommandLineArgs(ref idEmail, ref connectorCode);
                    filterEnginer = new SpamFilterEngine(idEmail, connectorCode);
                    filterEnginer.StartFilter();
                }
            }
        }
    }
}